DROP TABLE QVW_QORDER
GO
CREATE TABLE QVW_QORDER
AS
SELECT DISTINCT
QOKORDER AS QKAUF,QOKNEUD AS QNDATE,
SUBSTR(QOKNEUD,1,4) AS QNYEAR,
SUBSTR(QOKNEUD,5,2) AS QNMONTH,
SUBSTR(QOKNEUD,7,2) AS QNDAY,
'Q'||CEIL(TO_NUMBER(SUBSTR(QOKNEUD,5,2))/3) AS QNQUARTER,
QOKERLDAT AS QFDATE,
SUBSTR(QOKERLDAT,1,4) AS QFYEAR,
SUBSTR(QOKERLDAT,5,2) AS QFMONTH,
SUBSTR(QOKERLDAT,7,2) AS QFDAY,
QOKPNRKRS||QOKPLFDNR AS QPLAN,
QOKDYNTAB, QOKPRSFE,QOKPREINHT,
QOKARTST AS ARTST,QOKART AS PART,QOKVAR AS PVAR,QOKFARBE AS PCOLOR,QOKDESS AS PDESS,QOKCOLORIT AS PDCWY,QOKBESCHICH AS PFINISH,QOKGROE AS PSIZE,
QOKAUFTYP AS AUFTYP,
QOKAUFTYP||QOKAUFKRS||QOKAUFLFD AS KAUF,
QOKAUFTYP||QOKAUFKRS||QOKAUFLFD||QOKAUFPOS AS PAUF,
QOKAUFKRS  AS PKRS,QOKAUFLFD AS PLFD,QOKAUFPOS AS PPOS,QOKAFOLGE AS PFSTEP,
QOKMRESULT AS RESULT,
QOKTYPE
FROM QORDER WHERE QOKMANDANT='00'
GO

DROP TABLE QVW_QOSTEP
GO
CREATE TABLE QVW_QOSTEP
AS
SELECT DISTINCT
QOEORDER AS QKAUF,QOEORDER||QOESTEP AS QPAUF,
QOEPBENID AS HRSTAFF,
QOEPDATUM AS QXDATE,
SUBSTR(QOEPDATUM,1,4) AS QXYEAR,
SUBSTR(QOEPDATUM,5,2) AS QXMONTH,
SUBSTR(QOEPDATUM,7,2) AS QXDAY,
'Q'||CEIL(TO_NUMBER(SUBSTR(QOEPDATUM,5,2))/3) AS QXQUARTER,
QOEERLDAT AS QEDATE,
SUBSTR(QOEERLDAT,1,4) AS QEYEAR,
SUBSTR(QOEERLDAT,5,2) AS QEMONTH,
SUBSTR(QOEERLDAT,7,2) AS QEDAY,
'Q'||CEIL(TO_NUMBER(SUBSTR(QOEERLDAT,5,2))/3) AS QEQUARTER,
QOEPNRKRS||QOEPLFDNR AS QPLAN,
QOEMERKM AS MERKM,
QOEPGROE,QOEPGRKZ,
QOEMEEH AS QMEEH,
QOENSWERT*0.001 AS QOENSWERT,
QOEMWERT*0.001 AS QOEMWERT,
QOEMRESULT AS RESULT
FROM QOSTEP WHERE QOEMANDANT='00'
GO

DROP TABLE QVW_QPMERKM
GO
CREATE TABLE QVW_QPMERKM
AS
SELECT DISTINCT
QPMMERKM AS MERKM,
QPMKURZB AS MERKMBEZ,
QPMNORM AS QPSTD
FROM  QPMERKM WHERE QPMMANDANT='00'
GO
